#include <bits/stdc++.h>
// 2025/04/04
// tag:
// Author: Forever
using namespace std;
using int64 = int64_t;

int n, dp[101][101], dp2[101][101];
bool type[101];
char c;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    memset(dp2, 0x3f, sizeof(dp2));
    memset(dp, -0x3f, sizeof(dp));
    for (int i = 1; i <= n; i++)
        cin >> c >> dp[i][i], type[i] = type[i + n] = (c == 't'), dp[i + n][i + n] = dp2[i][i] = dp2[i + n][i + n] = dp[i][i];
    for (int len = 2; len <= n; len++)
        for (int l = 1, r = len; r <= n * 2; l++, r++)
            for (int k = l; k < r; k++)
                if (type[k + 1]){
                    dp[l][r] = max(dp[l][r], dp[l][k] + dp[k + 1][r]);
                    dp2[l][r] = min(dp2[l][r], dp2[l][k] + dp2[k + 1][r]);
                }
                else{
                    dp2[l][r] = min({dp2[l][r], dp2[l][k] * dp2[k + 1][r], dp2[l][k] * dp[k + 1][r], dp[l][k] * dp[k + 1][r]});
                    dp[l][r] = max({dp[l][r], dp[l][k] * dp[k + 1][r], dp2[l][k] * dp2[k + 1][r], dp[l][k] * dp[k + 1][r]});
                }
    int ans = 0;
    vector<int> v;
    for (int i = 1; i <= n; i++)
        if (dp[i][i + n - 1] > ans)
            ans = dp[i][i + n - 1], v.clear(), v.push_back(i);
        else if (dp[i][i + n - 1] == ans)
            v.push_back(i);
    cout << ans << endl;
    for (int i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    return 0;
}